package com.tcs.swing.action;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyItemListener implements ItemListener {

	private final Logger logger = LoggerFactory.getLogger(MyItemListener.class);

	private JRadioButton addRadioButton;

	private JRadioButton repRadioButton;

	private JLabel repStr;
	
	private JTextField repStrText;
	
	private JLabel destlabel;
	
	private JTextField destTextField;
	
	public MyItemListener(JRadioButton addRadioButton, JRadioButton repRadioButton) {
		super();
		this.addRadioButton = addRadioButton;
		this.repRadioButton = repRadioButton;
	}

	public MyItemListener(JRadioButton addRadioButton, JRadioButton repRadioButton, JLabel destlabel,
			JTextField destTextField, JLabel repStr, JTextField repStrText) {
		super();
		this.addRadioButton = addRadioButton;
		this.repRadioButton = repRadioButton;
		this.destlabel = destlabel;
		this.destTextField = destTextField;
		this.repStr = repStr;
		this.repStrText = repStrText;
	}

	public MyItemListener() {
		super();
	}

	@Override
	public void itemStateChanged(ItemEvent e) {
		if (e.getSource() == addRadioButton) {
			destlabel.setVisible(false);
			destTextField.setVisible(false);
			destlabel.setText("");
			destTextField.setText("");
			repStr.setText("添加标题");
			repStrText.setText("");
		} else {
			repStr.setText("原标题");
			repStrText.setText("");
			destlabel.setVisible(true);
			destTextField.setVisible(true);
			destlabel.setText("目标标题");
			destTextField.setText("");
		}
	}

}
